﻿@model Fish.Models.Events



@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        <h4>Events</h4>
        <hr />
        @Html.ValidationSummary(true)

        <div class="form-group">
            @Html.LabelFor(model => model.Name, new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Name)
                @Html.ValidationMessageFor(model => model.Name)
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.PrivacyType, new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.RadioButtonFor(model => model.PrivacyType, 0)
                @Html.LabelFor(model => model.PrivacyType, "Private")
                @Html.RadioButtonFor(model => model.PrivacyType, 1)
                @Html.LabelFor(model => model.PrivacyType, "Public")
                @Html.ValidationMessageFor(model => model.PrivacyType)
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.TemplatesID, "Templates", new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownList("TemplatesID", String.Empty)
                @Html.ValidationMessageFor(model => model.TemplatesID)
            </div>
            <input type="button" value="Create customized template" id="createTemplate" class=" btn btn-default" />


        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Create" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>
<script type="text/javascript">
    $(document).ready(function () {


        $("#createTemplate").click(function createTemplate() {
            var eventName = $("#Name").val();
            var eventPrivacy = $("#PrivacyType").val();

            var postData = { name: eventName, privacy: eventPrivacy };

            $.ajax({
                type: "POST",
                url: "/Events/CreateTemplate",
                data: postData,
                dataType: "json",
                traditional: true

            });
        });
    });

</script>
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
   